﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SPVSX.Project.Extensions.Wizards.Dialogs
{
    public partial class SPBasePermissionsPickerDialog : Form
    {
        #region Fields

        private string _selectedBasePermissions;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the selected base permissions
        /// </summary>
        public string SelectedBasePermissions
        {
            get;
            set;
        }

        #endregion

        public SPBasePermissionsPickerDialog()
        {
            InitializeComponent();
        }

        public SPBasePermissionsPickerDialog(string selectedBasePermissions)
        {
            InitializeComponent();
            SelectedBasePermissions = selectedBasePermissions;
        }

        private void lnkMSDNArticle_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {

        }

        private void SPBasePermissionsPickerDialog_Load(object sender, EventArgs e)
        {

        }

        private void MakeMeHappy()
        {
            //Call down to the sharepoint commands to get the enum values
        }

        ///// <summary>
        ///// Gets the description.
        ///// </summary>
        ///// <param name="enumerationValue">The enumeration value.</param>
        ///// <returns></returns>
        //public static string GetDescription(this object enumerationValue)
        //{
        //    Type type = enumerationValue.GetType();
        //    if (!type.IsEnum)
        //    {
        //        throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
        //    }
        //    //Tries to find a DescriptionAttribute     
        //    //for a potential friendly name   
        //    //for the enum
        //    MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString()); if (memberInfo != null && memberInfo.Length > 0)
        //    {
        //        object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); if (attrs != null && attrs.Length > 0)
        //        {
        //            //Pull out the description value             
        //            return ((DescriptionAttribute)attrs[0]).Description;
        //        }
        //    }
        //    //If we have no description attribute,     
        //    //just return the ToString of the enum     
        //    return enumerationValue.ToString();
        //}

        ///// <summary>
        ///// Get the description of an Enum type by its name
        ///// </summary>
        ///// <param name="enumValue">The enum value.</param>
        ///// <param name="defDesc">The string name of the enum value</param>
        ///// <returns>
        ///// The value fo the description attribute for that value
        ///// </returns>
        //public static string GetEnumDescriptionByName(object enumValue, string defDesc)
        //{
        //    FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString());

        //    if (null != fi)
        //    {
        //        object[] attrs = fi.GetCustomAttributes(typeof(DescriptionAttribute), true);
        //        if (attrs != null && attrs.Length > 0)
        //            return ((DescriptionAttribute)attrs[0]).Description;
        //    }

        //    return defDesc;
        //}
    }
}
